package utils.easyui;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import utils.UtilCollection;
import utils.easyui.domain.EzDatagrid;

public class UtilEzDatagrid {

	 /**
	    * @Title: getDataGridByHql
	    * @Description: 根据Hql 返回 包换 从po->vo 后的 dataGrid
	    * @param @param hql
	    * @param @param poClass PoClass.class
	    * @param @param voClass VoClass.class
	    * @param @return
	    * @param @throws CustomException
	    * @param @throws InstantiationException
	    * @param @throws IllegalAccessException    
	    * @return DataGrid    
	    * @throws
	    */
		public static <T> EzDatagrid<T> getDataGridByCollection(Collection<T> voCollection){
			EzDatagrid<T> dg = new EzDatagrid<>();
			if(!UtilCollection.isNullOrEmpty(voCollection)){
				List<T> list=new ArrayList<>();
				list.addAll(voCollection);
				dg.setRows(list);
				dg.setTotal((long) list.size());
			}else{
				dg.setRows(new ArrayList<T>());
				dg.setTotal(0L);
			}
			return dg;
		}
}
